//
//  BHStadiumDetailGoodModel.swift
//  BigHealth
//
//  Created by 布丁 on 2021/8/2.
//

import UIKit

class BHStadiumDetailGoodModel {
    var goodId: String = ""
    var name: String = ""
    
    var goods: [BHGoodsInfoModel] = []
    
    func parseDic(_ dic: [String: Any])  {
        self.goodId = BHJsonTool.decodeStringFromDic(dic: dic, key: "id")
        self.name = BHJsonTool.decodeStringFromDic(dic: dic, key: "name")

        let array = BHJsonTool.decodeArrayFromDic(dic: dic, key: "goods")
        for item in array {
            if item is NSNull {
                continue
            }else {
                let model = BHGoodsInfoModel.init()
                model.parseDic(item as! [String: Any])
                self.goods.append(model)
            }
        }
    }
}

class BHGoodsInfoModel {
    var goodId: String = ""
    var name: String = ""
    var price: String = ""
    var introduce: String = ""
    var cover: String = ""
    var typeId: String = ""
    var typeName: String = ""

    var purchaseNumber: Int = 0 // 购买次数

    
    func parseDic(_ dic: [String: Any])  {
        self.goodId = BHJsonTool.decodeStringFromDic(dic: dic, key: "id")
        self.name = BHJsonTool.decodeStringFromDic(dic: dic, key: "name")
        self.price = BHJsonTool.decodeStringFromDic(dic: dic, key: "price")
        self.introduce = BHJsonTool.decodeStringFromDic(dic: dic, key: "introduce")
        self.cover = BHJsonTool.decodeStringFromDic(dic: dic, key: "cover")
        self.typeId = BHJsonTool.decodeStringFromDic(dic: dic, key: "typeId")
        self.typeName = BHJsonTool.decodeStringFromDic(dic: dic, key: "typeName")

        self.purchaseNumber = BHJsonTool.decodeIntFromDic(dic: dic, key: "purchaseNumber")
        if self.purchaseNumber == -1 {
            self.purchaseNumber = 0
        }
    }

}


class BHGoodDetailModel {
    var goodId: String = ""
    var venueId: String = "" // 球馆id
    
    var name: String = ""
    var price: String = ""
    var introduce: String = ""
    var cover: String = ""
    var typeId: String = ""
    var typeName: String = ""
    
    var contactNumber: String = "" // 联系电话
    var contacts: String = "" // 联系人
    var backRule: String = "" //退改规则
    var discount: String = "" // 折扣
    var createTime: String = "" // 创建时间
    var images: [BHImageOrVideoModel] = []
    
    
    var purchaseNumber: Int = 0
    
    func parseDic(_ dic: [String: Any])  {
        self.goodId = BHJsonTool.decodeStringFromDic(dic: dic, key: "id")
        self.name = BHJsonTool.decodeStringFromDic(dic: dic, key: "name")
        self.price = BHJsonTool.decodeStringFromDic(dic: dic, key: "price")
        self.introduce = BHJsonTool.decodeStringFromDic(dic: dic, key: "introduce")
        self.cover = BHJsonTool.decodeStringFromDic(dic: dic, key: "cover")
        self.typeId = BHJsonTool.decodeStringFromDic(dic: dic, key: "typeId")
        self.typeName = BHJsonTool.decodeStringFromDic(dic: dic, key: "typeName")
        self.contactNumber = BHJsonTool.decodeStringFromDic(dic: dic, key: "contactNumber")
        self.contacts = BHJsonTool.decodeStringFromDic(dic: dic, key: "contacts")
        self.backRule = BHJsonTool.decodeStringFromDic(dic: dic, key: "backRule")
        self.discount = BHJsonTool.decodeStringFromDic(dic: dic, key: "discount")
        self.createTime = BHJsonTool.decodeStringFromDic(dic: dic, key: "createTime")


        self.purchaseNumber = BHJsonTool.decodeIntFromDic(dic: dic, key: "purchaseNumber")
        if self.purchaseNumber == -1 {
            self.purchaseNumber = 0
        }
        
        let array = BHJsonTool.decodeArrayFromDic(dic: dic, key: "images")
        for item in array {
            if item is NSNull {
                continue
            }else {
                let model = BHImageOrVideoModel.init()
                model.imageUrl = item as? String
                self.images.append(model)
            }
        }
    }
}
